package cn.itsource.basic.util;

import lombok.Data;

@Data
public class AjaxResult {
    private boolean success = true;
    private String message="操作";

    //有时除了返回成功或者失败和提示信息，有可能还要往前提返回一些数据，再加一个数据来属性
    private Object resultObj;

    //默认操作成功
    public AjaxResult() {
    }

    //操作失败
    public AjaxResult(String message) {
        this.success = false;
        this.message = message;
    }


    public static AjaxResult me(){
        return new AjaxResult();
    }

    public AjaxResult setSuccess(boolean success) {
        this.success = success;

        //我操作完了，返回自己继续操作
        return this;
    }

    public AjaxResult setMessage(String message) {
        this.message = message;
        return this;
    }

    public AjaxResult setResultObj(Object resultObj) {
        this.resultObj = resultObj;
        return this;
    }
}
